﻿package core {
    import events.GameDataEvent;
    
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.TimerEvent;
    import flash.utils.Timer;
    import flash.utils.getDefinitionByName;
	
    public class Game extends Sprite {

        private var container:GameContainer;
		
		private var model:Model = Model.instance;
		
        public function Game(){
            this.init();
			this.configEvent();
        }
		
		private function configEvent():void {
			model.addEventListener(GameDataEvent.UPDATE_SCORE_EVENT,updateScoreHandler);
			model.addEventListener(GameDataEvent.UPDATE_LIFE_EVENT,updateLifeHandler);
			model.addEventListener(GameDataEvent.UPDATE_LEVEL_EVENT,updateLevelHandler);
			model.addEventListener(GameDataEvent.UPDATE_CLEAR_NUM,updateClearNumHandler);
		}
		
		private function updateClearNumHandler(event:GameDataEvent):void {
			this.showProcess();
		}
		
		private function updateLevelHandler(event:GameDataEvent):void {
		}
		
		private function updateLifeHandler(event:GameDataEvent):void {
		}
		
		private function updateScoreHandler(event:GameDataEvent):void {
		}
		
        private function init():void{
            this.container = new GameContainer();
            addChild(this.container);
        }
		
        public function initGame():void {
			model.init();
			this.levelUp();
        }
		
        public function levelUp():void{
			model.levelUp();
			this.showProcess();
			this.container.initGame();
        }
		
        private function showProcess():void{
        }
    }
}
